package com.kefu.exam.vo;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;
import com.kefu.exam.model.ExamCascadeJump;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author xiaoyu
 * @date 2022/10/24
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "级联跳转规则表")
public class ExamCascadeJumpSearchVo extends AbstractSearchVo {

    @ApiModelProperty(value = "创建人")
    private String createUser;
    @ApiModelProperty(value = "创建时间开始")
    private Long createTimeStart;
    @ApiModelProperty(value = "创建时间结束")
    private Long createTimeEnd;
    @ApiModelProperty(value = "更新人")
    private String updateUser;
    @ApiModelProperty(value = "更新时间开始")
    private Long updateTimeStart;
    @ApiModelProperty(value = "更新时间结束")
    private Long updateTimeEnd;
    @ApiModelProperty(value = "问卷id")
    private String paperId;
    @ApiModelProperty(value = "问题id")
    private String subjectId;
    @ApiModelProperty(value = "问题答案id")
    private String answerId;
    @ApiModelProperty(value = "跳转问题id")
    private String jumpSubject;

	 @Override
    public  LambdaQueryWrapper<ExamCascadeJump> lambdaQuery(){
    	LambdaQueryWrapper<ExamCascadeJump> wrapper=Wrappers.<ExamCascadeJump>lambdaQuery();
	    wrapper.eq(StringUtils.isNotBlank(createUser), ExamCascadeJump::getCreateUser, createUser);
		wrapper.ge(createTimeStart!=null, ExamCascadeJump::getCreateTime, createTimeStart);
		wrapper.le(createTimeEnd!=null, ExamCascadeJump::getCreateTime, createTimeEnd);
	    wrapper.eq(StringUtils.isNotBlank(updateUser), ExamCascadeJump::getUpdateUser, updateUser);
		wrapper.ge(updateTimeStart!=null, ExamCascadeJump::getUpdateTime, updateTimeStart);
		wrapper.le(updateTimeEnd!=null, ExamCascadeJump::getUpdateTime, updateTimeEnd);
	    wrapper.eq(StringUtils.isNotBlank(paperId), ExamCascadeJump::getPaperId, paperId);
	    wrapper.eq(StringUtils.isNotBlank(subjectId), ExamCascadeJump::getSubjectId, subjectId);
	    wrapper.eq(StringUtils.isNotBlank(answerId), ExamCascadeJump::getAnswerId, answerId);
	    wrapper.eq(StringUtils.isNotBlank(jumpSubject), ExamCascadeJump::getJumpSubject, jumpSubject);
	    wrapper.eq(ExamCascadeJump::getTenantId, KefuContext.getKefuContext().getTenantId());
	    
    	return wrapper;
	}
}